package com.maiji.cloud.controller.shopingmall;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.shopingmall.ProvinceCity;
import com.maiji.cloud.entities.shopingmall.RuleFreight;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseMetaResDto;
import com.maiji.cloud.response.BaseResDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/settings")
@Api(tags = {"规则设置模块"})
public class SettingsController extends BaseController {

    /**
     *  获取运费规则列表
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "获取运费规则列表")
    @PostMapping("findAllRuleFreights")
    public BaseMetaResDto<List<RuleFreight>> findAllRuleFreights (@RequestBody BaseDataReqDto<RuleFreight> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/shippingAddress/findAllRuleFreights", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     *  添加/修改运费规则
     * @param baseDataReqDto
     * @return
     */
    @ApiOperation(value = "添加/修改运费规则")
    @PostMapping("add_updRuleFreight")
    public BaseResDto add_updRuleFreight (@RequestBody BaseDataReqDto<RuleFreight> baseDataReqDto) {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/shippingAddress/add_updRuleFreight", baseDataReqDto, BaseResDto.class);
    }

    /**
     *  获取全国省市列表
     * @return
     */
    @ApiOperation(value = "获取全国省市列表")
    @PostMapping("findAllProvinceCity")
    public BaseDataResDto<List<ProvinceCity>> findAllProvinceCity () {
        return restTemplate.postForObject(REST_URL_SHOPINGMALL + "/shippingAddress/findAllProvinceCity", null, BaseDataResDto.class);
    }

}
